home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 6.6 KB | 176 lines | [TEXT/MPS ] |
- // UTracker.h
- // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
-
-
- #ifndef __UTRACKER__
- #define __UTRACKER__
-
- // MacApp
-
- #ifndef __UCOMMAND__
- #include "UCommand.h"
- #endif
-
- #ifndef __UGEOMETRY__
- #include "UGeometry.h"
- #endif
-
- //----------------------------------------------------------------------------------------
- // Forward and external class declarations.
- //----------------------------------------------------------------------------------------
-
- class TScroller;
- class TView;
-
- //----------------------------------------------------------------------------------------
- // TTracker: Handles a user command, including undoing and mouse-tracking if required.
- // Usually created by the part of the Application with the greatest specific knowledge
- // about the action to take in response to events and passed back to be performed at
- // several well defined places.
- //----------------------------------------------------------------------------------------
-
- class TTracker : public TCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TTracker();
- // Empty constructor to satisfy compiler.
- virtual ~TTracker();
- // Destructor
-
- TView* fView; // The view in which tracking takes place
-
- VPoint fInitialPt; // Where to track from (usually where the
- // mouse went down).In coordinates of the
- // fView (that's being tracked) else if
- // the fView is NULL in global coordinates.
-
- Boolean fConstrainsMouse; // Defaults to false; if you set to true
- // then TrackConstrain will be called to
- // constrain the mouse.
-
- Boolean fViewConstrain; // Defaults to true, which means constrain
- // mouse to view limits
-
- Boolean fTrackNonMovement; // Defaults to false, which means don't
- // track mouse unless it moves.
-
- TScroller* fScroller; // The scroller that handles
- // auto-scrolling
-
- TrackPhase fTrackPhase;
-
- VPoint fAnchorPoint;
- VPoint fPreviousPoint;
- VPoint fNextPoint;
-
- VPoint fLastAnchorPoint;
- VPoint fLastPreviousPoint;
- VPoint fLastNextPoint;
-
- GrafPtr fDeskTopTrackingPort;
- CPoint fHysteresis;
- Boolean fMovedOnce;
-
- //------------------------------------------------------------------------------------
- // Init & Free
- //------------------------------------------------------------------------------------
-
- void ITracker(CommandNumber itsCommandNumber,
- TCommandHandler* itsContext,
- Boolean canUndo,
- Boolean causesChange,
- TObject* objectToNotify,
- TView* itsView,
- TScroller* itsScroller,
- const VPoint& itsMouse);
- // Initialize a command procedurally.
-
-
- //------------------------------------------------------------------------------------
- // Command Processing
- //------------------------------------------------------------------------------------
-
- virtual void Process(); // Override
- // Overridden to call TApplication::TrackMouse.
-
-
- //------------------------------------------------------------------------------------
- // Mouse Tracking
- //------------------------------------------------------------------------------------
-
- virtual Boolean IsDoneTracking();
- // Indicates whether the Command is through tracking. (the command is also through
- // tracking if you return NULL from TrackMouse). Defaults to fView->IsDoneTracking.
- // Most programs won't have to mess with this. NOTE you still have to deal with
- // queued events if you change the criteria for true.
-
- virtual void TrackConstrain(TrackPhase aTrackPhase,
- const VPoint& anchorPoint,
- const VPoint& previousPoint,
- VPoint& nextPoint,
- Boolean mouseDidMove);
- // Override this if you want to constrain the mouse CPoint to a grid, force drawing
- // a square, etc. This is called only if fConstrainsMouse is true.
-
- virtual void TrackFeedback(TrackPhase aTrackPhase,
- const VPoint& anchorPoint,
- const VPoint& previousPoint,
- const VPoint& nextPoint,
- Boolean mouseDidMove,
- Boolean turnItOn);
- // Default is: IF NOT mouseDidMove THEN FrameRect(<CRect formed by anchorPoint and
- // nextPoint>). Before this is called the pen is set to PenNormal and the PenMode
- // to PatXOR.
-
- virtual TTracker* TrackMouse(TrackPhase aTrackPhase,
- VPoint& anchorPoint,
- VPoint& previousPoint,
- VPoint& nextPoint,
- Boolean mouseDidMove);
- // This does the mouse tracking. The default returns this. Override it to force
- // gridding, to return a different type of command, or to perform the command on
- // mouse release instead of using the usual DoIt approach. All points are in local
- // coordinates. If aTrackPhase = trackPress then all 3 points will be the same. If
- // aTrackPhase = trackRelease then nextPoint will be the coordinate in the mouseUp
- // event (if a mouseUp event is found), otherwise the same CPoint as previousPoint.
- // Generally, you will ignore nextPoint and just look at previousPoint.
- // mouseDidMove will be true if aTrackPhase = trackPress or trackRelease;
- // otherwise, it will indicate if nextPoint = previousPoint. If you change
- // anchorPoint, the new value will be passed to you next time. The value of
- // nextPoint at the time the routine exits will be passed to you as previousPoint
- // the next time the routine is called. You can change nextPoint if you wish.
- // Usually, however, you will do gridding in the TrackConstrain method.
-
- virtual void AutoScroll(const VPoint& delta);
- // Implements autoscrolling by calling fScroller->ScrollBy.
-
-
- //------------------------------------------------------------------------------------
- // Managing the tracking. You don't usually call these… MacApp does
- //------------------------------------------------------------------------------------
-
- virtual void CleanUpFocus();
-
- virtual void DoFocus();
-
- virtual void BecomeTracker(TTracker* oldTracker);
-
- virtual void FeedbackOnce(Boolean mouseDidMove,
- Boolean turnItOn);
-
- virtual void ConstrainOnce(Boolean didMouseMove);
-
- virtual TTracker* TrackOnce(Boolean didMouseMove);
-
- virtual TTracker* HandleTrackBegin(const VPoint& theMouse, CPoint hysteresis);
-
- virtual TTracker* HandleTrackContinue();
-
- virtual TTracker* HandleTrackEnd();
-
- };
-
-
- #endif // __UTRACKER__